package cn.action.result;

import cn.entity.CheckResult;
import cn.entity.ClaimVoucher;
import cn.entity.Employee;
import cn.service.claim.CheckResultBiz;
import cn.service.claim.ClaimVoucherBiz;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import java.util.Date;
import java.util.Map;

public class CheckResultAction extends ActionSupport {
    private String toMethod;
    private CheckResult checkResult;
    private CheckResultBiz checkResultBiz;
    private ClaimVoucherBiz claimVoucherBiz;

    public String checkClaimVoucher(){
        Map session = ActionContext.getContext().getSession();
        Employee employee = (Employee) session.get("employee");
        checkResult.setCheckTime(new Date());
        checkResult.setCheckEmployee(employee);
        checkResultBiz.saveOrUpdate(checkResult);
        ClaimVoucher claimVoucher = claimVoucherBiz.findById(checkResult.getClaimId());
        claimVoucher.setStatus(checkResult.getResult());
        claimVoucherBiz.saveOrUpdate(claimVoucher);
        toMethod="/claimVoucher_searchClaimVoucher.action";
        return "success-action";
    }

    public String getToMethod() {
        return toMethod;
    }

    public void setToMethod(String toMethod) {
        this.toMethod = toMethod;
    }

    public CheckResult getCheckResult() {
        return checkResult;
    }

    public void setCheckResult(CheckResult checkResult) {
        this.checkResult = checkResult;
    }

    public ClaimVoucherBiz getClaimVoucherBiz() {
        return claimVoucherBiz;
    }

    public void setClaimVoucherBiz(ClaimVoucherBiz claimVoucherBiz) {
        this.claimVoucherBiz = claimVoucherBiz;
    }

    public CheckResultBiz getCheckResultBiz() {
        return checkResultBiz;
    }

    public void setCheckResultBiz(CheckResultBiz checkResultBiz) {
        this.checkResultBiz = checkResultBiz;
    }
}
